package pers.lonestar.framework.utils.support.analysis.handler;

import org.xml.sax.Attributes;

import pers.lonestar.framework.utils.support.constants.ExcelXmlConstants;
import pers.lonestar.framework.utils.support.contexts.XlsxReadContext;
import pers.lonestar.framework.utils.support.enums.CellDataTypeEnum;
import pers.lonestar.framework.utils.support.metadata.CellData;
import pers.lonestar.framework.utils.support.metadata.read.ReadSheet;
import pers.lonestar.framework.utils.support.utils.PositionUtil;

public class CellTagHandler extends AbstractXlsxTagHandler {
    @Override
    public void startElement(XlsxReadContext xlsxReadContext, ReadSheet readSheet, String name, Attributes attributes) {
        readSheet.setColumnIndex(PositionUtil.getCol(attributes.getValue(ExcelXmlConstants.ATTRIBUTE_R), readSheet.getColumnIndex()));

        CellDataTypeEnum cellType = CellDataTypeEnum.getFromCellType(attributes.getValue(ExcelXmlConstants.ATTRIBUTE_T));
        readSheet.setTempData(new StringBuilder());
        readSheet.setTempCellData(new CellData<>(cellType));
    }
}
